package org.oos.dao.options;

import java.util.ArrayList;
import java.util.List;

import com.google.api.client.util.Key;

/**
 * Defines the options that can be used to filter the search.
 * 
 * TODO: need to work with the tags and categories. Multiple attributes not
 * supported yet.
 * 
 * @author pablo.gonzalez@11870.com
 * 
 */
public class FilterOptions extends OptionsMap {

	private static final long serialVersionUID = -8182127074006321769L;

	public enum Scope {
		GLOBAL, USER, CONTACTS;
	}

	public enum Filter {
		Offers;
	}

	@Key("category")
	private List<String> categories = new ArrayList<String>();
	@Key("categoryGroup")
	private List<String> categoryGroups = new ArrayList<String>();
	@Key("attribute")
	private List<String> attributes = new ArrayList<String>();
	@Key("filters")
	private List<String> filters = new ArrayList<String>();

	public void addCategory(String category) {
		categories.add(category);
	}

	public void addAttribute(String attribute) {
		attributes.add(attribute);
	}

	public boolean removeCategory(String category) {
		return categories.remove(category);
	}

	public boolean removeAttribute(String attribute) {
		return attributes.remove(attribute);
	}

	public boolean removeCategoryGroup(String categoryGroup) {
		return categoryGroups.remove(categoryGroup);
	}

	@Override
	public void clear() {
		categories.clear();
		attributes.clear();
		categoryGroups.clear();
		filters.clear();
	}

	public void addCategoryGroup(String categoryGroup) {
		categoryGroups.add(categoryGroup);
	}

	public void addFilter(String filter) {
		filters.add(filter);
	}

	public void addFilter(Filter filter) {
		addFilter(filter.name().toLowerCase());
	}

	public void removeFilter(String filter) {
		filters.remove(filter);
	}

	public void removeFilter(Filter filter) {
		removeFilter(filter.name().toLowerCase());
	}
	
	// full access helpers
	
	public void setAttributes(List<String> attributes) {
		this.attributes = attributes;
	}
	
	public void setCategoryGroups(List<String> categoryGroups) {
		this.categoryGroups = categoryGroups;
	}
	
	public void setCategories(List<String> categories) {
		this.categories = categories;
	}
	
	public void setFilters(List<String> filters) {
		this.filters = filters;
	}
	
	public List<String> getAttributes() {
		return attributes;
	}
	
	public List<String> getCategories() {
		return categories;
	}
	
	public List<String> getCategoryGroups() {
		return categoryGroups;
	}
	
	public List<String> getFilters() {
		return filters;
	}

}
